package webjoch.process.strategies;

import java.awt.Graphics2D;
import java.util.ArrayList;

import com.rsbuddy.event.events.MessageEvent;

import webjoch.wrappers.Room;
/**
 * 
 * @author Webjoch
 *
 */
public abstract class Puzzle{
	public enum Type{
		MONOLITH,
		SLIDING_BLOCK,
		EMOTE,
		TRAPS,
		LARGE_CRYSTAL,
		THREE_STATUES,
		IMBUE_TILES,
		MAZE,
		WINCH_BRIDGE,
		SLIDING_STATUES,
		GHOSTS,
		DEMAGED_CONSTRUCT,
		LEVERS,
		PONDSKATERS,
		ICE_PAD;
	}
	private Type[] priority = {Type.TRAPS,
			Type.MAZE,
			Type.WINCH_BRIDGE,
			Type.MONOLITH};
	
	public Room room;
	
	protected ArrayList<Room> solvedRooms = new ArrayList<Room>();
	
	/**
	 * Set the puzzle room
	 * @param room room
	 */
	public void setRoom(Room room){
		this.room = room;
	}
	
	/**
	 * Checks if the given room is a valid
	 * @return true if there is a puzzle; otherwise false
	 */
	public abstract boolean isValid();

	/**
	 * Gets the the type of the puzzle
	 * @return puzzle typoe
	 */
	public abstract Puzzle.Type getType();
	
	/**
	 * will be solve the loop
	 * @return milliseconds to wait for the next tick
	 */
	public abstract int loop();
	
	/**
	 * Items needed to solve the puzzle
	 * @return needed item id`s
	 */
	public abstract int[] itemNeed();
	
	/**
	 * Checks if the puzzle is finished
	 * @return returns true if finished; otherwise false 
	 */
	public abstract boolean isFinished();
	
	public abstract void onRepaint(Graphics2D g);
	
	public abstract void messageReceived(MessageEvent e);
	
	/**
	 * Checks if the puzzle has priority to solve first the puzzle in the room
	 * @return returns true if the puzzle has priority; otherwise false
	 */
	public boolean hasPriority(){
		for (Type onePriority : priority){
			if (onePriority == getType()) return true;
		}
		return false;
	}
}